package csel.view.dialog;

import csel.model.entity.NonPlayerCharacter;

import java.awt.event.ActionListener;

import javax.swing.*;

import csel.controller.bindings.StringActionCommands;

public class NPCDialogueDialog extends JPanel
{
	private JTextArea dlg;
	private JButton buttons[];
	private ActionListener myListener;
	private JScrollPane jsp;
	
	/**
	 * Constructor
	 * 
	 * Receives a dialogue string, a string array of the options and an action listener.
	 * @param dialogue
	 * @param options
	 * @param a
	 */
	public NPCDialogueDialog(NonPlayerCharacter npc, ActionListener myListener){
		this.myListener = myListener;
		
		String dialogue = npc.getDialogue();
		
		dlg = new JTextArea(dialogue);
		dlg.setLineWrap(true);
		dlg.setWrapStyleWord(true);
		dlg.setEditable(false);
		jsp = new JScrollPane(dlg);
		
		this.setOpaque(false);
		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
		this.setSize(275,80);
		add(jsp);
		
		JPanel bottom = new JPanel();
		bottom.setLayout(new BoxLayout(bottom, BoxLayout.LINE_AXIS));
		add(bottom);
		/*(buttons = new JButton[options.length];	
		
		for(int x = 0; x < options.length; x++){
					buttons[x] = new JButton();
					buttons[x].setSize(50, 50);
					buttons[x].setText(options[x]);					
					buttons[x].addActionListener(myListener);
					bottom.add(buttons[x], BorderLayout.SOUTH);
		}	*/
		JButton myButton = new JButton();
		myButton.setText("Trade");
		myButton.setActionCommand(StringActionCommands.SHOW_TRADE_DIALOG);
		myButton.addActionListener(myListener);
		myButton.setFocusable(false);
		bottom.add(myButton);
		
		myButton = new JButton();
		myButton.setText("Attack");
		myButton.setActionCommand(StringActionCommands.ATTACK);
		myButton.addActionListener(myListener);
		myButton.setFocusable(false);
		bottom.add(myButton);
		
		myButton = new JButton();
		myButton.setText("Do Nothing");
		myButton.setActionCommand(StringActionCommands.HIDE_DIALOG);
		myButton.addActionListener(myListener);
		myButton.setFocusable(false);
		bottom.add(myButton);	
		
		revalidate();
		repaint();
	}
	
	public void show(){
		this.setVisible(true);
	}
	
}
